const pages = require('./plugin/multi-page')
const path = require('path')

function resolve(dir) {
    return path.join(__dirname, dir)
}

const px2remFilter = require('./plugin/postcss/postcss-px2rem-filter')
module.exports = {
    pages,
    publicPath: '',
    productionSourceMap: false,
    chainWebpack: config => {
        // key,value自行定义，比如.set('@@', resolve('src/components'))
        config.resolve.alias.set('@pc', resolve('src/pages/pc'))
        config.resolve.alias.set('@m', resolve('src/pages/mobile'))
        config.module
            .rule('images')
            .use('url-loader')
            .loader('url-loader')
            .tap(options => Object.assign(options, {limit: 1000}))
    },
    devServer: {
        // proxy: {
        //     '/api': {
        //         target: '',
        //         changeOrigin: true
        //     }
        // },
        port: 80,
        disableHostCheck: true
    },
    css: {
        loaderOptions: {
            postcss: {
                plugins: [
                    px2remFilter({
                        remUnit: 75,
                        include: ['/pages/mobile']
                    })
                ]
            }
        }
    }
}
